package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhTrainingResults;
import com.yinhe.system.service.IYhTrainingResultsService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * 训练综合成绩评定Controller
 * 
 * @author yinhe
 * @date 2022-09-24
 */
@RestController
@RequestMapping("/system/results")
public class YhTrainingResultsController extends BaseController
{
    @Autowired
    private IYhTrainingResultsService yhTrainingResultsService;

    /**
     * 查询训练综合成绩评定列表
     */
    @PreAuthorize("@ss.hasPermi('system:results:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhTrainingResults yhTrainingResults)
    {
        startPage();
        List<YhTrainingResults> list = yhTrainingResultsService.selectYhTrainingResultsList(yhTrainingResults);
        return getDataTable(list);
    }

    /**
     * 导出训练综合成绩评定列表
     */
    @PreAuthorize("@ss.hasPermi('system:results:export')")
    @Log(title = "训练综合成绩评定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhTrainingResults yhTrainingResults)
    {
        List<YhTrainingResults> list = yhTrainingResultsService.selectYhTrainingResultsList(yhTrainingResults);
        ExcelUtil<YhTrainingResults> util = new ExcelUtil<YhTrainingResults>(YhTrainingResults.class);
        util.exportExcel(response, list, "训练综合成绩评定数据");
    }

    /**
     * 获取训练综合成绩评定详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:results:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhTrainingResultsService.selectYhTrainingResultsById(id));
    }

    /**
     * 新增训练综合成绩评定
     */
    @PreAuthorize("@ss.hasPermi('system:results:add')")
    @Log(title = "训练综合成绩评定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhTrainingResults yhTrainingResults)
    {
        return toAjax(yhTrainingResultsService.insertYhTrainingResults(yhTrainingResults));
    }

    /**
     * 修改训练综合成绩评定
     */
    @PreAuthorize("@ss.hasPermi('system:results:edit')")
    @Log(title = "训练综合成绩评定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhTrainingResults yhTrainingResults)
    {
        return toAjax(yhTrainingResultsService.updateYhTrainingResults(yhTrainingResults));
    }

    /**
     * 删除训练综合成绩评定
     */
    @PreAuthorize("@ss.hasPermi('system:results:remove')")
    @Log(title = "训练综合成绩评定", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhTrainingResultsService.deleteYhTrainingResultsByIds(ids));
    }
}
